import React, { PureComponent } from 'react';
import moment from 'moment';
import { connect } from 'dva';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Card } from 'antd';
import StandardTable from '@/components/StandardTable';

@connect(({ integratedqueryns, loading }) => ({
  loading: loading.models.integratedqueryns,
  empInsRefundInfoList: integratedqueryns.empInsRefundInfoList, // 减员任务列表数据
}))
@Form.create()
class EmpInfor extends PureComponent {
  jumpRouting = (targetRouter, refundInfoId, type) => {
    const { jumpRouting } = this.props;
    jumpRouting(targetRouter, refundInfoId, type);
  };

  render() {
    const columns = [
      {
        title: '服务类型',
        dataIndex: 'serTypeIdName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '状态',
        dataIndex: 'stateName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '客户名称',
        dataIndex: 'custName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '返款金额',
        dataIndex: 'refundAmt',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
        render: text => text && text.toFixed(2),
      },
      {
        title: '添加时间',
        dataIndex: 'creTime',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
        render: text => text && moment(text).format('YYYY-MM-DD HH:mm'),
      },
      {
        title: '操作',
        dataIndex: 'operName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder', width: 150 } }),
        render: (text, record) => (
          <span
            style={{ color: '#1890FF', cursor: 'pointer' }}
            onClick={() => this.jumpRouting('refundInfoId', record.refundInfoId, 1)}
          >
            查看
          </span>
        ),
      },
    ];
    const { empInsRefundInfoList, loading } = this.props;
    return (
      <div>
        <Card
          style={{ marginBottom: 12 }}
          title={<span style={{ fontWeight: 'bolder' }}>返款信息</span>}
          bordered={false}
          extra={<a onClick={() => this.jumpRouting('refundInfoId')}>更多&gt;&gt;</a>}
          id="rebateinformation"
        >
          <StandardTable
            selectedRows={[]}
            selectedRowKeys={[]}
            loading={loading}
            data={empInsRefundInfoList}
            rowSelection={null}
            columns={columns}
            rowKey="refundInfoId"
            pagination={false}
          />
        </Card>
      </div>
    );
  }
}

export default EmpInfor;
